﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Microsoft.Surface;
using Microsoft.Surface.Presentation.Controls;
using Microsoft.Surface.Core;
using Microsoft.Surface.Presentation;

namespace ENMAX_ArcGIS
{
    /// <summary>
    /// A representation of a TroubleTicketPin used
    /// as a "pin" to identify the location of
    /// a TroubleTicket on a map.
    /// </summary>
    public class TroubleTicketPin : ScatterViewItem
    {
        #region members and properties

        private Point scr_pt;
        private TroubleTicket tTicket;
        private bool toggle;
        private TextBlock descriptionBlock;
        private ArcGisMapTip _mapTip;
        private TwoPointScatterView tpScatterView;

        public ArcGisMapTip MapTip
        {
            get
            {
                return _mapTip;
            }
            set
            {
                _mapTip = value;
            }
        }
        /// <summary>
        /// The description block of the TroubleTicketPin
        /// </summary>
        public TextBlock DescriptionBlock
        {
            get
            {
                return descriptionBlock;
            }
            set
            {
                this.descriptionBlock = value;
            }
        }

        /// <summary>
        /// The X cordinate of the pin on screen
        /// </summary>
        public int X
        {
            get
            {
                return (int)scr_pt.X;
            }
        }

        /// <summary>
        /// The Y cordinate of the pin on screen
        /// </summary>
        public int Y
        {
            get
            {
                return (int)scr_pt.Y;
            }
        }

        public Point ScreenPt
        {
            get
            {
                return scr_pt;
            }
            set
            {
                scr_pt = value;
            }
        }

        /// <summary>
        /// Trouble Ticket number
        /// </summary>
        public string Number
        {
            get
            {
                return tTicket.Number;
            }
        }

        /// <summary>
        /// String description about the TroubleTicket
        /// </summary>
        public string Description
        {
            get
            {
                return tTicket.Description;
            }
        }

        public TroubleTicket.TroubleTicketSeverity Severity
        {
            get
            {
                return tTicket.Severity;
            }
            set
            {
                tTicket.Severity = value;
            }
        }

        public TwoPointScatterView ScatterView
        {
            set
            {
                tpScatterView = value;
            }
        }


        public string getTroubleTicketSeverityString()
        {
            switch (tTicket.Severity)
            {
                case TroubleTicket.TroubleTicketSeverity.High: { return "High"; }
                case TroubleTicket.TroubleTicketSeverity.Medium: { return "Medium"; }
                case TroubleTicket.TroubleTicketSeverity.Low: { return "Low"; }
                default: { return string.Empty; }
            }
        }

        /// <summary>
        /// Gets the represented TroubleTicket of 
        /// this pin
        /// </summary>
        public TroubleTicket TroubleTicket
        {
            get
            {
                return tTicket;
            }
        }

        #endregion


        #region Constructors
        /// <summary>
        /// Constructor for TroubleTicketPin.  Takes in
        /// the represented TroubleTicket and the screen
        /// point as arguments.
        /// </summary>
        /// <param name="troubleTicket"></param>
        /// <param name="screenPoint"></param>
        public TroubleTicketPin(TroubleTicket troubleTicket, Point screenPoint)
        {
            tTicket = troubleTicket;
            scr_pt = screenPoint;

        }



        public TroubleTicketPin(Point screenPoint)
        {
            scr_pt = screenPoint;
        }

        #endregion

        /// <summary>
        /// This is called when the pin is tapped by a user.
        /// Keeps track if the description box is active.
        /// </summary>
        public void Tap()
        {
            if (toggle)
                toggle = false;
            else
                toggle = true;
        }

        /// <summary>
        /// Returns a TextBlock as the description block.
        /// </summary>
        /// <returns></returns>
        public TextBlock GetDescriptionBlock()
        {
            return descriptionBlock;
        }
    }

}

